﻿using System;
using Thuoc24h.Business;
using Thuoc24h.Common;
using CSS.Common;

namespace Thuoc24h.Home.Pages
{
    public partial class NewsByCategory : BasePage.BasePages
    {
        private int _id;
        private int PageSize = AppSettings.GetInt32("NewsPageSize");
        protected void Page_Load(object sender, EventArgs e)
        {
            _id = Page.RouteData.Values["id"].ToInt32Return0();
            var page = Request.QueryString["page"].ToInt32Return0();
            if (!Page.IsPostBack)
            {
                var listNews = ReviewRepository.GetNewsCategoryId(_id, page,pagerNews.PageSize);
                ltrCate.Text = Page.Title = ReviewRepository.GetCategoryById(_id).Name;
                lvNewsByCategory.DataSource = listNews;
                lvNewsByCategory.DataBind();
                var listcout = ReviewRepository.GetNewsCategoryId(_id);
                listViewPager.DataSource = listcout;
                listViewPager.DataBind();

                //if (listNews.Count <= PageSize)
                //{
                //    pagerNews.Visible = false;
                //}
            }
        }
    }
}